from rest_framework.viewsets import ModelViewSet #封装完成的ModeViewset 视图集
from app01.models import Sensor,Project,Data,Drawing #具体有的类
from app01.serializer import SensorSerializer,ProjectSerializer,DataSerializer,DrawingSerializer
from app01.filter import SensorFilter,ProjectFilter,DataFilter,DrawingFilter
from app01.paginations import MyPageNumberPagination

from django import render

# Create your views here.

# Sensor 视图
class SensorViewSet(ModelViewSet):
  queryset = Sensor.objects.all()
  serializer_class = SensorSerializer
  # 指定筛选的类
  filter_class = SensorFilter

# Project视图
class ProjectViewSet(ModelViewSet):
  queryset = Project.objects.all()
  serializer_class = ProjectSerializer
  # 指定筛选的类
  filter_class = ProjectFilter

# Data视图
class DataViewSet(ModelViewSet):
  queryset = Data.objects.all()
  serializer_class = DataSerializer
  # 指定筛选的类
  filter_class = DataFilter

# Drawing视图
class DrawingViewSet(ModelViewSet):
  queryset = Drawing.objects.all()
  serializer_class = DrawingSerializer
  pagination_class = MyPageNumberPagination
  print('eeee4444',queryset)


  # 指定筛选的类
  filter_class = DrawingFilter
  # 指定查找匹配的字段
  search_fields = ('drawing_name', 'material_code', 'drawing_spec', 'drawing_client_id')

def item_info(request):

  return render(request,'item_list.html')